<?php

/**
 * Returns whether the device is responsive or not
 */
function wmi_isPing($netbios) {
	try {
		$obj = new COM("winmgmts:");
		$wmi_Win32_PingStatus = $obj->ExecQuery("Select * from Win32_PingStatus"
				." WHERE Address=\"$netbios\""
				);
	}
	catch(Exception $e) {
		echo "\n(*)isPing: [\n". $e->getMessage() ."\n])\n";
		return false;
	}

	foreach($wmi_Win32_PingStatus as $wmi_call) {
		// only if StatusCode is set, and set to zero
		if($wmi_call->StatusCode === 0) {
			//echo "(isPing: ". $wmi_call->ResponseTime .")\n";
			return true;
		}
	}

	return false;
}

?>
